<%-- 
    Document   : OrderInfo
    Created on : 2020-4-20, 10:49:08
    Author     : zhang
--%>

<%@page import="dao.BookDao"%>
<%@page import="entity.Book"%>
<%@page import="entity.OrderInfo"%>
<%@page import="java.util.List"%>
<%@page import="entity.Address"%>
<%@page import="dao.AddressDao"%>
<%@page import="dao.OrderDao"%>
<%@page import="entity.OrderForm"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>订单信息</h1>
        <%
            String name=(String)session.getAttribute("username");
        %>
        <div style="position: absolute;left:300px;top:50px"><a href="Member.jsp?name=<%=name%>">返回个人主页</a></div>
        <%
            int orderId=Integer.parseInt(request.getParameter("orderid"));
            OrderForm orderform=new OrderDao().getOrderFormById(orderId);
            
            Address address=new AddressDao().getAddressById(orderform.getAddressId());
            
        %>
        <h3>收货地址：<%=address.getAddress()%></h3>
        <h3>收件人：<%=address.getAddressee()%></h3>
        <h3>购买时间：<%=orderform.getOrderDate()%></h3>
        <h3>购买图书：</h3>
        <%
            List<OrderInfo> list=new OrderDao().getOrderInfo(orderId);
            float total=0;
            for(OrderInfo orderinfo:list){
                Book book=new BookDao().getBookById(orderinfo.getBookId());
                int count=orderinfo.getCount();
        %>
        <div>
                <h3><%=book.getBookName()%></h3>
                <div style="width: 200px;height:300px;border:1px solid #000">
                    <img src="img/<%=book.getCover()%>" width="200px" height="300px" alt="<%=book.getBookName()%>">
                </div>
                <div style="width: 300px;height:250px" >
                    <p>编号：<%=book.getId()%></p>
                    <p>作者：<%=book.getAuthor()%></p>
                    <p>数量：<%=count%></p>
                    <p>单价：<%=book.getPrice()%></p>
                    
                    <a href="BookInfo.jsp?bookid=<%=book.getId()%>" target="blank">查看更多</a>
                </div>               
            </div>
                <%
                    total+=count*book.getPrice();
                    }
                %>
                <h1>实付款：<%=total%></h1>
                <%
                    if(orderform.getIsCheck()==false){
                %>
                <h1><a href="ocs?orderid=<%=orderId%>">确认收货</a></h1>
                <%
                    }else{
                %>
                <h1>已确认收货！</h1>
                <%
                    }
                %>
                
                <%
                    if(orderform.getRate()==0){
                %>
                <h3>订单评价：<a href="ors?rate=1&orderid=<%=orderId%>">1分</a>/<a href="ors?rate=2&orderid=<%=orderId%>">2分</a>/<a href="ors?rate=3&orderid=<%=orderId%>">3分</a>/<a href="ors?rate=4&orderid=<%=orderId%>">4分</a>/<a href="ors?rate=5&orderid=<%=orderId%>">5分</a></h3>
                <%
                    }else{
                %>
                <h3>已评价，评分：<%=orderform.getRate()%></h3>
                <%
                    }
                %>
    </body>
</html>
